<?php
/**
 * Created by PhpStorm.
 * User: SCKJ
 * Date: 16/1/21
 * Time: 下午9:58
 */

namespace Actions;


class ActionUtils
{

    public static function getResponseData($data,$event,$requestId,$result,$errMsg = null)
    {
        // 返回数据
        $response_data = array();
        // 事件类型
        $response_data[SYS_EVENT] = $event;
        // 通讯ID
        $response_data[REQUEST_ID] = $requestId ;
        // 响应码
        $response_data[RESULT] = $result;
        // 数据
        if ($data) {
            $response_data[DATA_DICTIONARY] = $data ;
        }
        // 错误信息
        if ($errMsg) {
            $response_data[ERROR_MSG] = $errMsg;
        }

        $json = json_encode( $response_data);

        //echo "***** \n ".$json." **** \n";

        return $json;
        //return json_encode( $response_data);
    }

    public static function checkUid($uid)
    {
        if(empty($uid)){
            //ErrorMsg::sendErr("会话已过期",OPE_UPDATE_SESSION,ERR_TYPE_SILENT);
            return true;
//            throw new MyException ("会话已过期",OPE_UPDATE_SESSION,ERR_TYPE_SILENT);
        }
        return false;
    }

}